package com.TwinBlade.PicturePassword;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.app.WallpaperManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Button;
import java.io.File;
import java.io.FileOutputStream;
import org.acra.ACRA;
import org.acra.ErrorReporter;

public class Crop extends Activity
{
  private Bitmap a;
  private Bitmap b;
  private TouchImageView c;
  private Context d;
  private ProgressDialog e;
  private ProgressDialog f;
  private Handler g;
  private Runnable h;

  private int a(BitmapFactory.Options paramOptions, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    int i = paramOptions.outHeight;
    int j = paramOptions.outWidth;
    int k = 1;
    if ((i > paramInt2) || (j > paramInt1))
    {
      if (i <= j)
        break label63;
      if (paramBoolean)
        k = Math.round(j / paramInt1);
    }
    else
    {
      return k;
    }
    return Math.round(i / paramInt2);
    label63: if (paramBoolean)
      return Math.round(i / paramInt2);
    return Math.round(j / paramInt1);
  }

  private String a(Uri paramUri)
  {
    try
    {
      Cursor localCursor = managedQuery(paramUri, new String[] { "_data" }, null, null, null);
      if (localCursor != null)
      {
        startManagingCursor(localCursor);
        int i = localCursor.getColumnIndexOrThrow("_data");
        localCursor.moveToFirst();
        return localCursor.getString(i);
      }
      String str = paramUri.getPath();
      return str;
    }
    catch (Exception localException)
    {
    }
    return paramUri.getPath();
  }

  private void a()
  {
    Drawable localDrawable = WallpaperManager.getInstance(this).getDrawable();
    int i = localDrawable.getMinimumHeight();
    int j = localDrawable.getMinimumWidth();
    this.a = Bitmap.createBitmap(j, i, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(this.a);
    localDrawable.setBounds(0, 0, j, i);
    localDrawable.draw(localCanvas);
  }

  private void a(boolean paramBoolean)
  {
    if (getIntent().getData() != null);
    for (Uri localUri = getIntent().getData(); ; localUri = null)
    {
      if (localUri == null)
      {
        setResult(0);
        finish();
      }
      while (true)
      {
        return;
        BitmapFactory.Options localOptions = new BitmapFactory.Options();
        localOptions.inJustDecodeBounds = true;
        try
        {
          BitmapFactory.decodeStream(getContentResolver().openInputStream(localUri), null, localOptions);
          Display localDisplay = getWindowManager().getDefaultDisplay();
          localOptions.inSampleSize = a(localOptions, localDisplay.getWidth(), localDisplay.getHeight(), paramBoolean);
          localOptions.inJustDecodeBounds = false;
          localMatrix = new Matrix();
        }
        catch (Exception localException2)
        {
          while (true)
          {
            try
            {
              str = new ExifInterface(a(localUri)).getAttribute("Orientation");
              if (str.equals("6"))
              {
                localMatrix.postRotate(90.0F);
                i = 1;
              }
            }
            catch (Exception localException2)
            {
              try
              {
                Matrix localMatrix;
                String str;
                Bitmap localBitmap2 = BitmapFactory.decodeStream(getContentResolver().openInputStream(localUri), null, localOptions);
                localBitmap1 = localBitmap2;
                if (localBitmap1 == null)
                  break;
                if (i != 0)
                {
                  this.a = Bitmap.createBitmap(localBitmap1, 0, 0, localBitmap1.getWidth(), localBitmap1.getHeight(), localMatrix, true);
                  localBitmap1.recycle();
                  return;
                  localException1 = localException1;
                  ACRA.getErrorReporter().a(localException1);
                  continue;
                  if (str.equals("3"))
                  {
                    localMatrix.postRotate(180.0F);
                    i = 1;
                    continue;
                  }
                  if (!str.equals("8"))
                    break label295;
                  localMatrix.postRotate(270.0F);
                  i = 1;
                  continue;
                  localException2 = localException2;
                  i = 0;
                  continue;
                }
              }
              catch (Exception localException3)
              {
                ACRA.getErrorReporter().a(localException3);
                Bitmap localBitmap1 = null;
                continue;
                this.a = localBitmap1;
                return;
              }
            }
            label295: int i = 0;
          }
        }
      }
    }
  }

  private boolean a(Bitmap paramBitmap)
  {
    try
    {
      FileOutputStream localFileOutputStream = openFileOutput("PhotoData.jpg", 0);
      paramBitmap.compress(Bitmap.CompressFormat.PNG, 90, localFileOutputStream);
      localFileOutputStream.close();
      return true;
    }
    catch (Exception localException)
    {
      ACRA.getErrorReporter().a(localException);
    }
    return false;
  }

  private boolean a(File paramFile, Bitmap paramBitmap)
  {
    try
    {
      FileOutputStream localFileOutputStream = new FileOutputStream(paramFile);
      paramBitmap.compress(Bitmap.CompressFormat.PNG, 90, localFileOutputStream);
      localFileOutputStream.close();
      return true;
    }
    catch (Exception localException)
    {
      ACRA.getErrorReporter().a(localException);
    }
    return false;
  }

  private boolean b()
  {
    return (this.c.getDrawable() != null) && (this.c.getDrawable().getIntrinsicHeight() != 0) && (this.c.getDrawable().getIntrinsicWidth() != 0);
  }

  @SuppressLint({"NewApi"})
  public void onCreate(Bundle paramBundle)
  {
    String str = PreferenceManager.getDefaultSharedPreferences(this).getString("ForceOrientation", "0");
    if (str.equals("0"))
      if (!Utilities.a())
        setRequestedOrientation(1);
    while (true)
    {
      super.onCreate(paramBundle);
      requestWindowFeature(1);
      this.d = this;
      this.g = new Handler();
      this.h = new o(this);
      setContentView(2130903041);
      this.c = ((TouchImageView)findViewById(2131230723));
      this.c.setMaxZoom(4.0F);
      if (Build.VERSION.SDK_INT > 10)
        this.c.setLayerType(1, null);
      Button localButton1 = (Button)findViewById(2131230724);
      Button localButton2 = (Button)findViewById(2131230725);
      localButton1.setOnClickListener(new p(this));
      localButton2.setOnClickListener(new q(this));
      new r(this, null).execute(new Void[0]);
      return;
      setRequestedOrientation(0);
      continue;
      if (str.equals("1"))
        setRequestedOrientation(1);
      else if (str.equals("2"))
        setRequestedOrientation(0);
    }
  }

  public void onDestroy()
  {
    super.onDestroy();
    this.c.setDrawingCacheEnabled(false);
    if (this.a != null)
    {
      this.a.recycle();
      this.a = null;
    }
    if (this.b != null)
    {
      this.b.recycle();
      this.b = null;
    }
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     com.TwinBlade.PicturePassword.Crop
 * JD-Core Version:    0.6.2
 */